iT邦幫忙

0

PYTHON 學習筆記 015

  • 分享至 

  • xImage
  •  
#class and object 物件函式 VS  一般函式
#物件函式的第一個參數為reference物件本身"SELF"
class Personality:
    def __init__(self,bloodtype,sexual,pets,is_graduated):
        self.bloodtype = bloodtype
        self.sexual = sexual
        self.pets = pets
        self.is_graduated = is_graduated

    def check_graduated_status(self):
        return self.is_graduated
    
    

person1 = Personality("A","Female",2,True)
print (person1.sexual,person1.check_graduated_status())
person2 = Personality("O","Male",33,False)
print (person2.pets)

https://ithelp.ithome.com.tw/upload/images/20230226/20156136RpBKESR3XH.jpg


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言